﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using System.Data;
using System.Data.SqlClient;

[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ProductService
{

    DataSet ds = new DataSet();
    SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
    SqlCommand cmd = new SqlCommand();

    [OperationContract]
    [WebInvoke(Method = "POST",
        ResponseFormat = WebMessageFormat.Json,
        RequestFormat = WebMessageFormat.Json)]
    public string saveSalesUserProducts(string product, string brand,
        string model, string series, string color, string motherBoard,
        string processor, string ram, string screenType,
        string screenSize, string opticalDiskDrive, string usb,
        string modemEthernet, string bluetooth, string tvOutput,
        string soundCard, string keyboardAndMouse, string accessories,
        string operatingSystem, string graphicsCard, string hardDrive,
        string screenResolution, string memoryCardReader,
        string wifi, string audioInterface, string expansionCardslot,
        string webcam, string battery, string softwareIncluded, string price, string discount,
        string homeDelivery)
    {
        try
        {

            decimal priceValue;
            decimal discountValue;
            int homeDeliveryValue;
            priceValue = ((decimal.TryParse(price, out priceValue) ? (Convert.ToDecimal(price)) : 0));
            discountValue = ((decimal.TryParse(discount, out discountValue) ? (Convert.ToDecimal(discount)) : 0));
            homeDeliveryValue = ((Int32.TryParse(homeDelivery, out homeDeliveryValue) ? (Convert.ToInt32(homeDelivery)) : 0));


            cmd.Connection = con;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "MAS_pInventryDetailsInsert";
            cmd.Parameters.Add(new SqlParameter("@Product", SqlDbType.VarChar)).Value = product;
            cmd.Parameters.Add(new SqlParameter("@Brand", SqlDbType.VarChar)).Value = brand;
            cmd.Parameters.Add(new SqlParameter("@Model", SqlDbType.VarChar)).Value = model;
            cmd.Parameters.Add(new SqlParameter("@Series", SqlDbType.VarChar)).Value = series;
            cmd.Parameters.Add(new SqlParameter("@Color", SqlDbType.VarChar)).Value = color;
            cmd.Parameters.Add(new SqlParameter("@MotherBoard", SqlDbType.VarChar)).Value = motherBoard;
            cmd.Parameters.Add(new SqlParameter("@Processor", SqlDbType.VarChar)).Value = processor;
            cmd.Parameters.Add(new SqlParameter("@Ram", SqlDbType.VarChar)).Value = ram;
            cmd.Parameters.Add(new SqlParameter("@ScreenType", SqlDbType.VarChar)).Value = screenType;
            cmd.Parameters.Add(new SqlParameter("@ScreenSize", SqlDbType.VarChar)).Value = screenSize;
            cmd.Parameters.Add(new SqlParameter("@OpticalDiskdrive", SqlDbType.VarChar)).Value = opticalDiskDrive;
            cmd.Parameters.Add(new SqlParameter("@Usb", SqlDbType.VarChar)).Value = usb;
            cmd.Parameters.Add(new SqlParameter("@ModemEthernet", SqlDbType.VarChar)).Value = modemEthernet;
            cmd.Parameters.Add(new SqlParameter("@Bluetooth", SqlDbType.VarChar)).Value = bluetooth;
            cmd.Parameters.Add(new SqlParameter("@TVOutput", SqlDbType.VarChar)).Value = tvOutput;
            cmd.Parameters.Add(new SqlParameter("@SoundCard", SqlDbType.VarChar)).Value = soundCard;
            cmd.Parameters.Add(new SqlParameter("@KeyboardAndMouse", SqlDbType.VarChar)).Value = keyboardAndMouse;
            cmd.Parameters.Add(new SqlParameter("@Accessories", SqlDbType.VarChar)).Value = accessories;
            cmd.Parameters.Add(new SqlParameter("@OperatingSystem", SqlDbType.VarChar)).Value = operatingSystem;
            cmd.Parameters.Add(new SqlParameter("@GraphicsCard", SqlDbType.VarChar)).Value = graphicsCard;
            cmd.Parameters.Add(new SqlParameter("@HardDrive", SqlDbType.VarChar)).Value = hardDrive;
            cmd.Parameters.Add(new SqlParameter("@ScreenResolution", SqlDbType.VarChar)).Value = screenResolution;
            cmd.Parameters.Add(new SqlParameter("@MemoryCardReader", SqlDbType.VarChar)).Value = memoryCardReader;
            cmd.Parameters.Add(new SqlParameter("@Wifi", SqlDbType.VarChar)).Value = wifi;
            cmd.Parameters.Add(new SqlParameter("@AudioInterface", SqlDbType.VarChar)).Value = audioInterface;
            cmd.Parameters.Add(new SqlParameter("@ExpantionCardSlot", SqlDbType.VarChar)).Value = expansionCardslot;
            cmd.Parameters.Add(new SqlParameter("@Webcam", SqlDbType.VarChar)).Value = webcam;
            cmd.Parameters.Add(new SqlParameter("@Battery", SqlDbType.VarChar)).Value = battery;
            cmd.Parameters.Add(new SqlParameter("@SoftwareIncluded", SqlDbType.VarChar)).Value = softwareIncluded;
            cmd.Parameters.Add(new SqlParameter("@Price", SqlDbType.Decimal)).Value = priceValue;
            cmd.Parameters.Add(new SqlParameter("@Discount", SqlDbType.Decimal)).Value = discountValue;
            cmd.Parameters.Add(new SqlParameter("@Homedelivery", SqlDbType.Int)).Value = homeDeliveryValue;
            SqlDataAdapter sda = new SqlDataAdapter(cmd);

            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            sda.Fill(ds);
            con.Close();

        }
        catch (Exception)
        {

            throw;
        }


       return "{Status:'" + ds.Tables[0].Rows[0]["status"] + "' }";

    }

    [OperationContract]
    [WebInvoke(Method = "POST",
        ResponseFormat = WebMessageFormat.Json,
        RequestFormat = WebMessageFormat.Json)]
    public string fetchSalesUserProducts(string productId)
    {
        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "MAS_pFetchInventory";
        cmd.Parameters.Add("@p_id", SqlDbType.Int).Value = productId;
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        con.Open();
        sda.Fill(ds);
        con.Close();
        return "{Product:'" + ds.Tables[0].Rows[0]["Product"] + "',Brand: '" + ds.Tables[0].Rows[0]["Brand"] +
                "',Model:'" + ds.Tables[0].Rows[0]["Model"] + "',Series:'" + ds.Tables[0].Rows[0]["Series"] +
                "',MotherBoard:'" + ds.Tables[0].Rows[0]["MotherBoard"] + "',Color:'" + ds.Tables[0].Rows[0]["Color"] +
                "',Processor:'" + ds.Tables[0].Rows[0]["Processor"] + "',Ram:'" + ds.Tables[0].Rows[0]["Ram"] +
                "',ScreenType:'" + ds.Tables[0].Rows[0]["ScreenType"] + "',ScreenSize:'" + ds.Tables[0].Rows[0]["ScreenSize"] +
                "',OpticalDiskdrive:'" + ds.Tables[0].Rows[0]["OpticalDiskdrive"] + "',Usb:'" + ds.Tables[0].Rows[0]["Usb"] +
                "',ModemEthernet:'" + ds.Tables[0].Rows[0]["ModemEthernet"] + "',Bluetooth:'" + ds.Tables[0].Rows[0]["Bluetooth"] +
                "',TVOutput:'" + ds.Tables[0].Rows[0]["TVOutput"] + "',SoundCard:'" + ds.Tables[0].Rows[0]["SoundCard"] +
                "',KeyboardAndMouse:'" + ds.Tables[0].Rows[0]["KeyboardAndMouse"] + "',Accessories:'" + ds.Tables[0].Rows[0]["Accessories"] +
                "',OperatingSystem:'" + ds.Tables[0].Rows[0]["OperatingSystem"] + "',GraphicsCard:'" + ds.Tables[0].Rows[0]["GraphicsCard"] +
                "',ScreenResolution:'" + ds.Tables[0].Rows[0]["ScreenResolution"] + "',HardDrive:'" + ds.Tables[0].Rows[0]["HardDrive"] +
                "',MemoryCardReader:'" + ds.Tables[0].Rows[0]["MemoryCardReader"] + "',Wifi:'" + ds.Tables[0].Rows[0]["Wifi"] +
                "',AudioInterface:'" + ds.Tables[0].Rows[0]["AudioInterface"] + "',ExpantionCardSlot:'" + ds.Tables[0].Rows[0]["ExpantionCardSlot"] +
                "',Webcam:'" + ds.Tables[0].Rows[0]["Webcam"] + "',Battery:'" + ds.Tables[0].Rows[0]["Battery"] +
                "',SoftwareIncluded:'" + ds.Tables[0].Rows[0]["SoftwareIncluded"] + "',Price:'" + ds.Tables[0].Rows[0]["Price"] +
                "',Discount:'" + ds.Tables[0].Rows[0]["Discount"] + "',HomeDelivery:'" + ds.Tables[0].Rows[0]["HomeDelivery"] +
            "'}";

    }
    [OperationContract]
    [WebInvoke(Method = "POST",
        ResponseFormat = WebMessageFormat.Json,
        RequestFormat = WebMessageFormat.Json)]
    public string modifySalesUserProducts(int ProductID, string Product, string Brand, string Model, string Series, string Color, string MotherBoard, string OperatingSystem, string Processor, string GraphicsCard, String Ram, string ScreenResolution, string ScreenType, string HardDrive, string ScreenSize, string MemoryCardReader, string OpticalDiskDrive, string Usb, string Wifi, string ModemEthernet, string AudioInterface, string Bluetooth, string expansionCardslot, string TVOutput, string SoundCard, string KeyboardMouse, string Accessories, string Webcam, string Battery, String SoftwareIncluded, float Price, float Discount, string HomeDelivery)
    {
        DataSet ds = new DataSet();
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
        SqlCommand cmd = new SqlCommand();

        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "MAS_pInventryDetailsUpdate";
        cmd.Parameters.Add("@ID", SqlDbType.Int).Value = ProductID;
        cmd.Parameters.Add("@Product", SqlDbType.VarChar).Value = Product;
        cmd.Parameters.Add("@Brand", SqlDbType.VarChar).Value = Brand;
        cmd.Parameters.Add("@Model", SqlDbType.VarChar).Value = Model;
        cmd.Parameters.Add("@Series", SqlDbType.VarChar).Value = Series;
        cmd.Parameters.Add("@Color", SqlDbType.VarChar).Value = Color;
        cmd.Parameters.Add("@MotherBoard", SqlDbType.VarChar).Value = MotherBoard;
        cmd.Parameters.Add("@OperatingSystem", SqlDbType.VarChar).Value = OperatingSystem;
        cmd.Parameters.Add("@Processor", SqlDbType.VarChar).Value = Processor;
        cmd.Parameters.Add("@GraphicsCard", SqlDbType.VarChar).Value = GraphicsCard;
        cmd.Parameters.Add("@Ram", SqlDbType.VarChar).Value = Ram;
        cmd.Parameters.Add("@ScreenResolution", SqlDbType.VarChar).Value = ScreenResolution;
        cmd.Parameters.Add("@ScreenType", SqlDbType.VarChar).Value = ScreenType;
        cmd.Parameters.Add("@HardDrive", SqlDbType.VarChar).Value = HardDrive;
        cmd.Parameters.Add("@Screensize", SqlDbType.VarChar).Value = ScreenSize;
        cmd.Parameters.Add("@MemoryCardReader", SqlDbType.VarChar).Value = MemoryCardReader;
        cmd.Parameters.Add("@OpticalDiskDrive", SqlDbType.VarChar).Value = OpticalDiskDrive;
        cmd.Parameters.Add("@Usb", SqlDbType.VarChar).Value = Usb;
        cmd.Parameters.Add("@Wifi", SqlDbType.VarChar).Value = Wifi;
        cmd.Parameters.Add("@ModemEthernet", SqlDbType.VarChar).Value = ModemEthernet;
        cmd.Parameters.Add("@AudioInterface", SqlDbType.VarChar).Value = AudioInterface;
        cmd.Parameters.Add("@Bluetooth", SqlDbType.VarChar).Value = Bluetooth;
        cmd.Parameters.Add("@ExpantionCardSlot", SqlDbType.VarChar).Value = expansionCardslot;
        cmd.Parameters.Add("@TVOutput", SqlDbType.VarChar).Value = TVOutput;
        cmd.Parameters.Add("@SoundCard", SqlDbType.VarChar).Value = SoundCard;
        cmd.Parameters.Add("@KeyboardAndMouse", SqlDbType.VarChar).Value = KeyboardMouse;
        cmd.Parameters.Add("@Accessories", SqlDbType.VarChar).Value = Accessories;
        cmd.Parameters.Add("@Webcam", SqlDbType.VarChar).Value = Webcam;
        cmd.Parameters.Add("@Battery", SqlDbType.VarChar).Value = Battery;
        cmd.Parameters.Add("@SoftwareIncluded", SqlDbType.VarChar).Value = SoftwareIncluded;
        cmd.Parameters.Add("@Price", SqlDbType.Float).Value = Price;
        cmd.Parameters.Add("@Discount", SqlDbType.Float).Value = Discount;
        cmd.Parameters.Add("@HomeDelivery", SqlDbType.VarChar).Value = HomeDelivery;
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        con.Open();
        sda.Fill(ds);
        con.Close();
        return "{Message: '" + ds.Tables[0].Rows[0]["Message"] + "'}";
    }


    [OperationContract]
    [WebInvoke(Method = "POST",
        ResponseFormat = WebMessageFormat.Json,
        RequestFormat = WebMessageFormat.Json)]
    public string ftodSalesUserProducts(string pId)
    {
        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "MAS_pFetch";
        cmd.Parameters.Add("@p_id", SqlDbType.Int).Value = pId;
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        con.Open();
        sda.Fill(ds);
        con.Close();
        return "{Product:'" + ds.Tables[0].Rows[0]["Product"] + "',Brand: '" + ds.Tables[0].Rows[0]["Brand"] +
                "',Model:'" + ds.Tables[0].Rows[0]["Model"] + "',Series:'" + ds.Tables[0].Rows[0]["Series"] +
                "',Color:'" + ds.Tables[0].Rows[0]["Color"] +
        "'}";

    }


    [OperationContract]
    [WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    RequestFormat = WebMessageFormat.Json)]
    public string removeSalesUserProducts(int ProductID)
    {
        DataSet ds = new DataSet();
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
        SqlCommand cmd = new SqlCommand();

        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "MAS_pInventoryDelete";
        cmd.Parameters.Add("@InventoryID", SqlDbType.Int).Value = ProductID;
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        con.Open();
        sda.Fill(ds);
        con.Close();
        return "{Message: '" + ds.Tables[0].Rows[0]["Message"] + "'}";
    }


    [OperationContract]
    [WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    RequestFormat = WebMessageFormat.Json)]
    public string searchProducts(string Category, string Brand, string Model, string PriceFrom, string PriceTo)
    {
           /* decimal PriceFromValue;
            decimal PriceToValue;
            PriceFromValue = ((decimal.TryParse(PriceFrom, out PriceFromValue) ? (Convert.ToDecimal(PriceFrom)) : 0));
            PriceToValue = ((decimal.TryParse(PriceTo, out PriceToValue) ? (Convert.ToDecimal(PriceTo)) : 0));*/
            cmd.Connection = con;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "MAS_pSearch";
            cmd.Parameters.Add("@p_Category", SqlDbType.VarChar).Value = Category;
            cmd.Parameters.Add("@p_Brand", SqlDbType.VarChar).Value = Brand;
            cmd.Parameters.Add("@p_Model", SqlDbType.VarChar).Value = Model;
            cmd.Parameters.Add("@p_Pricefrm",SqlDbType.VarChar).Value = PriceFrom;
            cmd.Parameters.Add("@p_Priceto",SqlDbType.VarChar).Value = PriceTo;
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            con.Open();
            sda.Fill(ds);
            con.Close();
            
            StringBuilder json = new StringBuilder();
            int count = ds.Tables[0].Rows.Count;
            for (int start = 0; start < count; start++)
            {
                json.Append("{ProductID:'" + ds.Tables[0].Rows[start]["ID"] + "',Brand:'" + ds.Tables[0].Rows[start]["Brand"] + "',Model:'" + ds.Tables[0].Rows[start]["Model"] + "',Price:'"
                    + ds.Tables[0].Rows[start]["Price"] + "',Filepath:'" + ds.Tables[0].Rows[start]["FilePath"] + "'},");
            }
            json.Remove(json.Length - 1, 1);


            return "{'binding':[" + json.ToString() + "]}";
    }


    [OperationContract]
    [WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    RequestFormat = WebMessageFormat.Json)]
    public string searchHomeProducts(string Category, string Brand, string Model, string PriceFrom, string PriceTo)
    {
        /* decimal PriceFromValue;
         decimal PriceToValue;
         PriceFromValue = ((decimal.TryParse(PriceFrom, out PriceFromValue) ? (Convert.ToDecimal(PriceFrom)) : 0));
         PriceToValue = ((decimal.TryParse(PriceTo, out PriceToValue) ? (Convert.ToDecimal(PriceTo)) : 0));*/
        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "MAS_pSearchHome";
        cmd.Parameters.Add("@p_Category", SqlDbType.VarChar).Value = Category;
        cmd.Parameters.Add("@p_Brand", SqlDbType.VarChar).Value = Brand;
        cmd.Parameters.Add("@p_Model", SqlDbType.VarChar).Value = Model;
        cmd.Parameters.Add("@p_Pricefrm", SqlDbType.VarChar).Value = PriceFrom;
        cmd.Parameters.Add("@p_Priceto", SqlDbType.VarChar).Value = PriceTo;
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        con.Open();
        sda.Fill(ds);
        con.Close();

        StringBuilder json = new StringBuilder();
        int count = ds.Tables[0].Rows.Count;
        for (int start = 0; start < count; start++)
        {
            json.Append("{ProductID:'" + ds.Tables[0].Rows[start]["ID"] + "',Brand:'" + ds.Tables[0].Rows[start]["Brand"] + "',Model:'" + ds.Tables[0].Rows[start]["Model"] + "',Price:'"
                + ds.Tables[0].Rows[start]["Price"] + "',Filepath:'" + ds.Tables[0].Rows[start]["FilePath"] + "'},");
        }
        json.Remove(json.Length - 1, 1);


        return "{'binding':[" + json.ToString() + "]}";
    }


    [OperationContract]
    [WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    RequestFormat = WebMessageFormat.Json)]
    public string latestProducts()
    {
        /* decimal PriceFromValue;
         decimal PriceToValue;
         PriceFromValue = ((decimal.TryParse(PriceFrom, out PriceFromValue) ? (Convert.ToDecimal(PriceFrom)) : 0));
         PriceToValue = ((decimal.TryParse(PriceTo, out PriceToValue) ? (Convert.ToDecimal(PriceTo)) : 0));*/
        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "MAS_pGetLatestProducts";
        
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        con.Open();
        sda.Fill(ds);
        con.Close();

        StringBuilder json = new StringBuilder();
        int count = ds.Tables[0].Rows.Count;
        for (int start = 0; start < count; start++)
        {
            json.Append("{ProductID:'" + ds.Tables[0].Rows[start]["ID"] + "',Brand:'" + ds.Tables[0].Rows[start]["Brand"] + "',Model:'" + ds.Tables[0].Rows[start]["Model"] + "',Price:'"
                + ds.Tables[0].Rows[start]["Price"] + "',Filepath:'" + ds.Tables[0].Rows[start]["FilePath"] + "'},");
        }
        json.Remove(json.Length - 1, 1);


        return "{'binding':[" + json.ToString() + "]}";
    }


    
    
    
    [OperationContract]
    [WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    RequestFormat = WebMessageFormat.Json)]
    public string searchProductsList()
    {
        /* decimal PriceFromValue;
         decimal PriceToValue;
         PriceFromValue = ((decimal.TryParse(PriceFrom, out PriceFromValue) ? (Convert.ToDecimal(PriceFrom)) : 0));
         PriceToValue = ((decimal.TryParse(PriceTo, out PriceToValue) ? (Convert.ToDecimal(PriceTo)) : 0));*/

        //return "{{Brand:'Sony',Model:'vio',Price:40000},{Brand:'Dell',Model:'Ins',Price:35000},{Brand:'HP',Model:'vio',Price:40000}}";


        return "{total: '1', page: '1', records: '1',   rows : [{cell:['Dell,vio,40000']},{cell:['Sony,vio,40000']}]}";

    }



    [OperationContract]
    [WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    RequestFormat = WebMessageFormat.Json)]
    public string saveOrderInformation(string customerorder, string customername, string customermobile, string customeraddress, string customercity,string customerstate)
    {
        try
        {
            DataSet ds = new DataSet();
            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = con;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "Mas_porderConfirmation";
            cmd.Parameters.Add("@OrderedProducts", SqlDbType.VarChar).Value = customerorder;
            cmd.Parameters.Add("@CustomerName", SqlDbType.VarChar).Value = customername;
            cmd.Parameters.Add("@CustomerMobile", SqlDbType.BigInt).Value = customermobile;
            cmd.Parameters.Add("@CustomerAddress", SqlDbType.VarChar).Value = customeraddress;
            cmd.Parameters.Add("@CustomerCity", SqlDbType.VarChar).Value = customercity;
            cmd.Parameters.Add("@CustomerState", SqlDbType.VarChar).Value = customerstate;
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            con.Open();
            sda.Fill(ds);
            con.Close();
            return "{Message: '" + ds.Tables[0].Rows[0]["Message"] + "', Status :'" + ds.Tables[0].Rows[0]["Status"] + "',Confirmation :'" + ds.Tables[0].Rows[0]["Confirmation"] + "'  }";


        }
        catch (Exception)
        {
            return "{Message: 'Failed' ,Status :'2' }";
        }

    }


    [OperationContract]
    [WebInvoke(Method = "POST",
    ResponseFormat = WebMessageFormat.Json,
    RequestFormat = WebMessageFormat.Json)]
    public string getCustomer(string UserEmail)
    {
        DataSet ds = new DataSet();
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString);
        SqlCommand cmd = new SqlCommand();

        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "MAS_pFetchCustomer";
        cmd.Parameters.Add("@p_userMail", SqlDbType.VarChar).Value = UserEmail;
        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        con.Open();
        sda.Fill(ds);
        con.Close();
        return "{CustomerFirstname:'" + ds.Tables[0].Rows[0]["CustomerFirstname"] + "',CustomerMobile: '" + ds.Tables[0].Rows[0]["CustomerMobile"] +
                "',CustomerAddress1:'" + ds.Tables[0].Rows[0]["CustomerAddress1"] + "',CustomerAddress2:'" + ds.Tables[0].Rows[0]["CustomerAddress2"] +
                "',CustomerState:'" + ds.Tables[0].Rows[0]["CustomerState"] + "'}";
    }


    [OperationContract]
    public void DoWork()
    {

        return;
    }


}
